home *** CD-ROM | disk | FTP | other *** search
- unit Ufmgr1;
-
- interface
-
- uses
- SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
- Forms, Dialogs, StdCtrls, Buttons, ExtCtrls, ShellAPI, FileCtrl,
- drwsutl1, drwsutl2;
-
- type
- TCCFileMgrForm = class(TForm)
- Panel1: TPanel;
- Panel2: TPanel;
- BitBtn1: TBitBtn;
- Panel3: TPanel;
- Label1: TLabel;
- BitBtn2: TBitBtn;
- BitBtn3: TBitBtn;
- BitBtn4: TBitBtn;
- BitBtn5: TBitBtn;
- BitBtn6: TBitBtn;
- BitBtn7: TBitBtn;
- OpenDialog1: TOpenDialog;
- BitBtn8: TBitBtn;
- BitBtn9: TBitBtn;
- OpenDialog2: TOpenDialog;
- procedure FormResize(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- procedure BitBtn7Click(Sender: TObject);
- procedure BitBtn1Click(Sender: TObject);
- procedure BitBtn2Click(Sender: TObject);
- procedure BitBtn3Click(Sender: TObject);
- procedure BitBtn4Click(Sender: TObject);
- procedure BitBtn5Click(Sender: TObject);
- procedure FormPaint(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- ScrollBox1 : TFileIconPanelScrollbox;
- CurrentView : Integer; { This holds the current view setting }
- end;
- var
- CCFileMgrForm : TCCFileMgrForm;
-
- implementation
-
- {$R *.DFM}
-
- uses DDDFUnit; { Include custom directory selection form }
-
- { Set up the resize to replace the icon buttons }
- procedure TCCFileMgrForm.FormResize(Sender: TObject);
- begin
- { Send in the panel and global buttons list }
- SpacePanelButtons( Panel2 );
- end;
-
- { Delphi wrote this; use it to set everything up }
- procedure TCCFileMgrForm.FormCreate(Sender: TObject);
- var CurrentPath : String;
- begin
- { Create the scrollbox }
- ScrollBox1 := TFileIconPanelScrollBox.Create( Panel1 );
- ScrollBox1.Parent := Panel1;
- ScrollBox1.align := alClient;
- ScrollBox1.Left := 0;
- ScrollBox1.Top := 0;
- ScrollBox1.Width := Panel1.Width - 32;
- ScrollBox1.Height := Panel1.Height - 32;
- ScrollBox1.IconsNeedRefreshing := false;
- ScrollBox1.TheStoredHandle := Self.Handle;
- { Get the current directory with 0 parameter }
- GetDir( 0 , CurrentPath );
- { Set the display caption }
- Label1.Caption := CurrentPath;
- { Add a trailing \ if not root }
- CurrentPath := ScrollBox1.TheFWB.ForceTrailingBackSlash( CurrentPath );
- { Get the icons display using scrollbox1 }
- ScrollBox1.GetIconsForEntireDirectory( CurrentPath );
- { Set the Icon View as default }
- CurrentView := 1;
- end;
-
- { Delphi wrote this; use it to close the application }
- procedure TCCFileMgrForm.BitBtn7Click(Sender: TObject);
- begin
- Close;
- end;
-
- { Delphi wrote this use it to perform a copy on all selected files }
- procedure TCCFileMgrForm.BitBtn1Click(Sender: TObject);
- var ThePosition : Integer; { Loop counter }
- CurrentName , { Holds work name}
- TheOldString : String; { Holds Dir }
- finished : Boolean; { Loop control }
- WorkingDir : String; { Holds mod wd }
- TargetDir : String; { target of op }
- TheResult : Integer; { Modal res hold }
- begin
- { Get current directory and save it for later }
- GetDir( 0 , TheOldString );
- { Check for need to add trailing \ }
- WorkingDir := TheOldString;
- WorkingDir := ScrollBox1.TheFWB.ForceTrailingBackSlash( WorkingDir );
- { Display the Windows-based directory input form }
- TheResult := DestDDForm.ShowModal;
- { If not cancelled do the copy }
- if TheResult = mrOK then
- begin
- { Get the target directory with \ OK }
- TargetDir := DestDDForm.GetTargetDirectory;
- { Show the hourglass to indicate waiting }
- Screen.Cursor := crHourGlass;
- { Setup to get all selections }
- ThePosition := 1;
- finished := false;
- while not finished do
- begin
- { Call generic file getting routine based on current view}
- case CurrentView of
- 1 : CurrentName := ScrollBox1.GetNextSelection( WorkingDir ,
- ThePosition );
- end;
- { If returns blank string out of selections so exit }
- if CurrentName = '' then finished := true else
- begin
- { If a directory signal error }
- if (( FileGetAttr( CurrentName ) and faDirectory ) = faDirectory ) then
- begin
- MessageDlg( ' Cannot Copy Directory ' + CurrentName , mtConfirmation ,
- mbYesNoCancel , 0 );
- end
- else
- begin
- Scrollbox1.TheFWB.CopyTheFile( CurrentName , TargetDir );
- end;
- end;
- end;
- { Reset to normal cursor }
- Screen.Cursor := crDefault;
- end;
- { Reset to the original directory }
- ChDir( TheOldString );
- end;
-
- { Delphi wrote this, use it to move files which are selected }
- procedure TCCFileMgrForm.BitBtn2Click(Sender: TObject);
- var ThePosition : Integer; { Loop counter }
- CurrentName , { Holds work name}
- TheOldString : String; { Holds Dir }
- finished : Boolean; { Loop control }
- WorkingDir : String; { Holds mod wd }
- TargetDir : String; { target of op }
- TheResult : Integer; { Modal res hold }
- begin
- { Get current directory and save it for later }
- GetDir( 0 , TheOldString );
- { Check for need to add trailing \ }
- WorkingDir := TheOldString;
- WorkingDir := ScrollBox1.TheFWB.ForceTrailingBackSlash( WorkingDIr );
- { Display the Windows-based directory input form }
- TheResult := DestDDForm.ShowModal;
- { If not cancelled do the copy }
- if TheResult = mrOK then
- begin
- { Get the target directory with \ OK }
- TargetDir := DestDDForm.GetTargetDirectory;
- { Show the hourglass to indicate waiting }
- Screen.Cursor := crHourGlass;
- { Set up to get all current selections }
- ThePosition := 1;
- finished := false;
- while not finished do
- begin
- { Call generic file getting routine based on current view}
- case CurrentView of
- 1 : CurrentName := ScrollBox1.GetNextSelection( WorkingDir ,
- ThePosition );
- end;
- { If returns blank string then out of selections }
- if CurrentName = '' then finished := true else
- begin
- { If a directory signal error }
- if (( FileGetAttr( CurrentName ) and faDirectory ) = faDirectory ) then
- begin
- MessageDlg( 'Cannot Move Directory ' + CurrentName , mtConfirmation ,
- mbYesNoCancel , 0 );
- end
- else
- begin
- Scrollbox1.TheFWB.MoveTheFile( CurrentName , TargetDir );
- end;
- end;
- { Reset to normal cursor }
- Screen.Cursor := crDefault;
- end;
- end;
- { Reset to the original directory }
- ChDir( TheOldString );
- ScrollBox1.Update;
- end;
-
- { Delphi wrote this, use it to delete files which are selected }
- procedure TCCFileMgrForm.BitBtn3Click(Sender: TObject);
- var ThePosition : Integer; { Loop counter }
- CurrentName , { Holds work name}
- TheOldString : String; { Holds Dir }
- finished : Boolean; { Loop control }
- WorkingDir : String; { Holds mod wd }
- begin
- { Get current directory and save it for later }
- GetDir( 0 , TheOldString );
- { Check for need to add trailing \ }
- WorkingDir := TheOldString;
- WorkingDir := ScrollBox1.TheFWB.ForceTrailingBackSlash( WorkingDIr );
- { Set up to do loop for selected files }
- ThePosition := 1;
- finished := false;
- while not finished do
- begin
- { Call generic file getting routine based on current view}
- case CurrentView of
- 1 : CurrentName := ScrollBox1.GetNextSelection( WorkingDir ,
- ThePosition );
- end;
- { if returns blank string out of selections }
- if CurrentName = '' then finished := true else
- begin
- { If its a directory signal error }
- if (( FileGetAttr( CurrentName ) and faDirectory ) = faDirectory ) then
- begin
- MessageDlg( 'Cannot Delete Directory ' + CurrentName , mtConfirmation,
- mbYesNoCancel , 0 );
- end
- else
- begin
- { Otherwise get confirmation message and if OKed delete file }
- if MessageDlg( 'Delete file ' + CurrentName + '?', mtConfirmation ,
- mbYesNoCancel , 0 ) = mrYes then
- begin
- ScrollBox1.TheFWB.DeleteTheFile( Currentname );
- end;
- end;
- end;
- end;
- ScrollBox1.Update;
- end;
-
- { Delphi wrote this; use it to rename selected files }
- procedure TCCFileMgrForm.BitBtn4Click(Sender: TObject);
- var ThePosition : Integer; { Loop counter }
- CurrentName , { Holds work name}
- TheOldString : String; { Holds Dir }
- finished : Boolean; { Loop control }
- WorkingDir : String; { Holds mod wd }
- begin
- { Get current directory for later }
- GetDir( 0 , TheOldString );
- { Check for need to add trailing \ }
- WorkingDir := TheOldString;
- WorkingDir := ScrollBox1.TheFWB.ForceTrailingBackSlash( WorkingDIr );
- { Set up to do loop for selected files }
- ThePosition := 1;
- finished := false;
- while not finished do
- begin
- { Call generic file getting routine based on current view}
- case CurrentView of
- 1 : CurrentName := ScrollBox1.GetNextSelection( WorkingDir ,
- ThePosition );
- end;
- { If returns blank string then out of selections }
- if CurrentName = '' then finished := true else
- begin
- { Otherwise set up the opendialog with filename and caption }
- OpenDialog1.Filename := ExtractFilename( CurrentName );
- { Use this to prevent error from changing directories }
- OpenDialog1.Options := [ofNoChangeDir];
- OpenDialog1.Title := 'Rename File';
- { If not cancelled then do rename or signal error }
- if OpenDialog1.Execute then
- begin
- ScrollBox1.TheFWB.RenameTheFile( CurrentName , OpenDialog1.Filename );
- end;
- end;
- end;
- ScrollBox1.Update;
- end;
-
- { Delphi wrote this; use it to make a new directory under current one }
- procedure TCCFileMgrForm.BitBtn5Click(Sender: TObject);
- begin
- { Set up the dialog to get the new directory name }
- OpenDialog2.FileName := '*.*';
- OpenDialog2.Title := 'Enter Directory Name';
- if OpenDialog1.Execute then
- begin
- { If not cancelled make new directory }
- Scrollbox1.TheFWB.CreateNewDirectory( OpenDialog1.Filename );
- end;
- ScrollBox1.Update;
- end;
-
- { Delphi wrote this; use it to handle refreshing the scrollbox }
- procedure TCCFileMgrForm.FormPaint(Sender: TObject);
- var CurrentDirectory : String; { Get current dir }
- begin
- { If updated, do refresh }
- if ScrollBox1.IconsNeedRefreshing then
- begin
- Scrollbox1.Free;
- ScrollBox1 := TFileIconPanelScrollBox.Create( Panel1 );
- ScrollBox1.Parent := Panel1;
- ScrollBox1.align := alClient;
- ScrollBox1.Left := 0;
- ScrollBox1.Top := 0;
- ScrollBox1.Width := Panel1.Width - 32;
- ScrollBox1.Height := Panel1.Height - 32;
- ScrollBox1.IconsNeedRefreshing := false;
- ScrollBox1.TheStoredHandle := Self.Handle;
- GetDir( 0 , CurrentDirectory );
- { Force trailing backslash }
- CurrentDirectory := ScrollBox1.TheFWB.ForceTrailingBackSlash(
- CurrentDirectory );
- { Set the label to the new directory }
- Label1.Caption := UpperCase( CurrentDirectory );
- { Do the update }
- ScrollBox1.GetIconsForEntireDirectory( CurrentDirectory );
- end;
- end;
-
- end.
-